package com.princess.demok.utils

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup

/**
 * Created with Android Studio.
 * Description:
 * @author: Wangjianxian
 * @CreateDate: 2020/5/1 16:34
 */

inline fun <reified T> startActivity(context: Context) {
    val intent = Intent(context, T::class.java)
    context.startActivity(intent)
}

inline fun <reified T> startActivity(context: Context, block: Intent.() -> Unit) {
    val intent = Intent(context, T::class.java)
    intent.block()
    context.startActivity(intent)
}

/**
 * 显示水印背景
 * @param resId 水印layout文件
 */
fun Activity.showWatermarkView(resId: Int) {
    val rootView = window.decorView.findViewById<ViewGroup>(android.R.id.content);
    val framView = LayoutInflater.from(this).inflate(resId, null);
    rootView.addView(framView);
}